package cn.edu.cuc.yjsy.admin.dialogs;

import org.eclipse.jface.wizard.Wizard;

import cn.edu.cuc.yjsy.admin.controllers.StudentController;
import cn.edu.cuc.yjsy.admin.util.MessageHelper;

public class ImportWizard extends Wizard {
	
	private ImportFilePage filePage;
	protected boolean fileCompleted = false;
	
	public ImportWizard(){
		setWindowTitle(MessageHelper.WIZARD_IMPORT_TITLE);
	}

	public void addPages() {
		filePage = new ImportFilePage("file", 
				MessageHelper.WIZARD_LOCATIONPAGE_TITLE, null);
		addPage(filePage);
	}
	
	/**
	 * @override
	 */
	public boolean canFinish() {		
		return fileCompleted;
	}
	
	public boolean performFinish() {
		StudentController controller = new StudentController();
		controller.importData(filePage.getFilePath(), 
				"[" + filePage.getTableName() + "]", 
				filePage.isOverwrite());
		return true;
	}

}
